var userVm = new Vue({
    el: "#userPage",
    data: function () {
        return {
            page: {
                current: 1,
                size: 10,
                total: 0,
                records: [],
                condition: {
                    sesaId: "",
                    roleId: "",
                    chineseName: "",
                    businessTitleValue: "",
                    employeeStatus: "",
                    isEnable: ""
                }
            },
            userDialogVisible: false,
            tableHeight: "",
            checkedList: [],
            dictionaries: {},
            roles: [],
            form: {},
            formLabelWidth: '120px'
        }
    },
    computed: {},
    watch: {},
    methods: {
        selectable: function (row, index) {
            if (row.id === "ADMINISTRATORS") {
                return false;
            } else {
                return true;
            }
        },
        search: function () {
            VanyAjax("/sys/user/list", {
                current: this.page.current,
                size: this.page.size,
                condition: this.page.condition,
            }, "GET", ".el-table").done(function (data) {
                this.page.current = data.current;
                this.page.size = data.size;
                this.page.total = data.total;
                this.page.records = data.records;
                this.page.other = data.other;
                VanyAjax.prototype.hideLoading();
            }, false, this);
        },
        exportUser: function () {
            window.location.href = "/sys/user/export?" + jsonUtil.serialize(this.page.condition);
        },
        // 勾选角色的时候
        handleSelectionChange: function (selection) {
            this.checkedList = selection;
        },
        handleCurrentChange: function (val) {
            this.page.current = val;
            this.search();
        },
        handleSizeChange: function (val) {
            this.page.size = val;
            this.search();
        },
        showDetail: function (row) {
            userVm.userDialogVisible = true;
            this.form = row;
        },
        roleNameFormatter: function (row, column, cellValue) {
            return row.roleNames ? row.roleNames.join() : '-';
        },
        close: function () {
            userVm.userDialogVisible = false;
        }
    },
    mounted: function () {
        this.$el.style.left = "210px";
        this.tableHeight = window.innerHeight - 400;
        this.search();
        loadDictionaries(function (data) {
            userVm.dictionaries = data;
        });
        VanyAjax("/sys/role/list", {}, "GET").done(function (data) {
            userVm.roles = data;
        }, false, this);
    },
    updated: function () {
        Jurisdiction();
    }
});